package com.quotes.charts;

import java.awt.Color;

import org.jfree.chart.plot.XYPlot;
import org.jfree.data.time.*;
import org.jfree.data.xy.*;

import com.quotes.Parameters;
import com.quotes.datamodell.*;
import com.quotes.datamodell.TimeSeries;
import com.quotes.dates.*;
import com.quotes.indicators.*;

public class RsiChart extends LineChart
{
	private static final long serialVersionUID = 1L;
	private RsiIndicator indicator = null;
	
	public RsiChart(Quotes quotes, TimeRange range, int ticks) {
		super(quotes, range);
		
		indicator = new RsiIndicator(quotes, ticks);
		this.createChart(quotes);
		logger.debug("RsiChart created!");
	}
	
	protected XYDataset createXyDataset(Quotes product) {
		TimeSeriesCollection data = new TimeSeriesCollection();

    	TimeSeries rsi = indicator.getRsi();
    	rsi = rsi.extract(range);
    	data.addSeries(rsi.convertToChartTimeSeries("RSI"));
		
		return data;
	}
	
	@Override
	protected XYPlot manipulatePlot(XYPlot plot) {
		addVerticalMarker(plot, 30, Color.black);
		addVerticalMarker(plot, 70, Color.black);
		return plot;
	}
}
